package com.taotao.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.taotao.mapper.ContentMapper;
import com.taotao.pojo.Content;
import com.taotao.service.ContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * describe:
 *
 * @author hong.zheng
 * @date 2018/09/12
 */
@Service
public class ContentServiceImpl implements ContentService {
    @Autowired
    ContentMapper contentMapper;

    @Override
    public PageInfo<Content> getContentList(long catId, Integer page, Integer rows) {
        PageHelper.startPage(page, rows);
        List<Content> list = contentMapper.getContentList(catId);
        PageInfo<Content> pageInfo = new PageInfo<Content>(list);
        return pageInfo;
    }

    @Override
    public Content selectContent(long id) {
        return contentMapper.selectContent(id);
    }

    @Override
    public void insertContent(Content content) {
        content.setCreated(new Date());
        contentMapper.insertContent(content);
    }

    @Override
    public void updateContent(Content content) {
        content.setUpdated(new Date());
        contentMapper.updateContent(content);
    }

    @Override
    public void deleteContent(long []ids) {
        contentMapper.deleteContent(ids);
    }
}
